/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class Test_Trg_ServiceLetter
{

    static testMethod void myUnitTest()
    {
        // TO DO: implement unit test

        //Account Object...
        Account accountObject = new Account();
        accountObject.Name = 'Test Account';
        accountObject.License_Application_Step__c = 'Record Created';
        accountObject.License_Application_Type__c = 'New License';
        accountObject.Activity__c = 'Trading - Three Activity';
        accountObject.License_Issue_Date__c = system.today();
        accountObject.License_Expiry_Date__c = System.Today().addYears(1);
        insert accountObject;
        
        Transaction_Types__c transactionObject = new Transaction_Types__c();
        transactionObject.Transaction_Type_ID__c = 'Letter - Open Bank Account';
        transactionObject.Application_Record_Type__c = 'Service Letter - Bank Letter';
        insert transactionObject;
        
        // adding test data for Custiom setting 
        SLA_Custom_Setting__c SLAcustomSettingObject = new SLA_Custom_Setting__c();
        SLAcustomSettingObject.Name = 'test setting';
        SLAcustomSettingObject.Application_Type__c = 'Open Bank Account';
        SLAcustomSettingObject.Process_Type__c = 'Service Letter';
        SLAcustomSettingObject.SLA_Hours__c = 1;
        insert SLAcustomSettingObject; 
        
        // Service Letter Object ...
         Map<string,ID> recordTypeNameMap = new Map<string,ID>();
        for(RecordType recordTypeObject : [select id,DeveloperName from RecordType where sObjectType= 'Request__c' AND IsActive = true])
        {
            recordTypeNameMap.put(recordTypeObject.DeveloperName, recordTypeObject.id);
        }
        Request__c serviceLetterObject = new Request__c();
        serviceLetterObject.RecordTypeId  = recordTypeNameMap.get('Bank_Letter') ;
        serviceLetterObject.Request_Status__c = 'Under Process';
        serviceLetterObject.Company__c = accountObject.Id;
        serviceLetterObject.Transaction_Type__c = transactionObject.id;
        insert serviceLetterObject;
        
        //SLA Implementation...
        SLA__c slaObject = new SLA__c();
        slaObject.License__c = accountObject.Id;
        slaObject.Actual_Start_Date_Time__c= DateTime.Now();
        slaObject.Expected_End_Date__c= DateTime.Now().addYears(2);
        slaObject.SLA_Hours__c = SLAcustomSettingObject.SLA_Hours__c;
        slaObject.Process_Type__c = SLAcustomSettingObject.Process_Type__c;
        slaObject.Application_Type__c = SLAcustomSettingObject.Application_Type__c;//'Open Bank Account';
        slaObject.Actual_End_Date_Time__c= DateTime.Now().addYears(1);
        insert slaObject;
        
        serviceLetterObject.Request_Status__c = 'Cancelled';
        upsert serviceLetterObject;
        serviceLetterObject.Request_Status__c ='Scheduled for Delivery';
        upsert serviceLetterObject;
    }
}